# -*- coding: utf-8 -*-

from PyQt4 import QtGui, QtCore


class Answers:

    #def __init__(self, answerScheme = None):
    def __init__(self):
        self.__answers = {}
        # jak vypada odpoved
        #self.__answerScheme = answerScheme
        # pocet radku
        self.rowCount = 0
        # prefix pred kazdou otazkou, nemusi byt
        self.prefix = None


    def __iter__(self):
        for answer in self.__answers.values():
            yield answer


    def add(self, answer):
        self.__answers[self.rowCount] = answer
        

    def getAnswer(self):
        answer = []
        #try:
        for widget in self.__answerScheme:
            answer.append(widget())
            #answer.append(widget)
        #except Exception, e:
            #raise KeyError, "Unkown answer widget type - %s" % e

        return answer

    def delete(self, answer):
        self.__answers.pop(answer)

    def clear(self):
        #print self.__answers
        self.__answers = {}
        #print "hoho"


    def deleteButton(self):
        answerDelete = QtGui.QPushButton()
        answerDelete.setIcon(QtGui.QIcon(":/icons/delAnswerIcon"))

        #QtCore.QObject.connect(answerDelete, QtCore.SIGNAL("clicked()"), self.clear)

        return answerDelete


    def setScheme(self, scheme):
        self.__answerScheme = scheme

    #scheme = property(getScheme, setScheme)

    def setPrefix(self, prefix):
        self.prefix = prefix
    